<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>客户关系管理</title>
    <jsp:include page="../../head.jsp"/>
</head>
<script type="text/javascript">
    var s = "${MODIFIER}";
    var formSetting = {
        title: "客户关系管理",
        module: 'save',
        columns: [{
            name: "company.name",
            label: "客户公司",
            readonly: true
        }, {
            name: "customerRole.ID",
            label: "角色",
            type: "dropdown",
            dropdownType: "ajax",
            url: "../base/dropdown-supCustomerRole",
            minLength: 0
        }, {
            name: "REMARK",
            label: "备注",
            type: "textarea"
        }, {
            name: "ID",
            label: "id",
            hidden: true
        }, {
            name: "COM_ID",
            label: "com_id",
            hidden: true
        }],
        form: {
            'url': 'supCustomer-saveOrUpdate',
            'data': function () {
                var id = "${ID}";
                if (id) {
                    var dataValue = "";
                    $.ajax({
                               url: "supCustomer-find?ID=" + id,
                               async: false,
                               success: function (data) {
                                   if (data.customerRole != null) {
                                       var dropdownName = $.mrdForm.getDropDwonLabelName(
                                               "customerRole.ID");
                                       data[dropdownName] = data.customerRole.NAME;
                                   }
                                   dataValue = data;
                               }
                           });
                    return dataValue;
                } else {
                    return null;
                }
            },
            afterAjaxSuccess: function (responseText, statusText, xhr, $form) {
                if ($.parseJSON(responseText.msg).state == 1) {
                    //$('#center', window.parent.document).attr("src","supCustomer-main");
                    window.location.href = "supCustomer-main";
                }
            }
        },
        buttons: {}
    };
    $(document).ready(function () {
        $("#formtable").mrdForm(formSetting);
    });
</script>
<body>
<div style="width: 100%">
    <div id="formtable"></div>
</div>
</body>
</html>
